package org.levi.demo.service.impl;

import org.levi.demo.dao.ResumeDao;
import org.levi.demo.entity.Resume;
import org.levi.demo.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

@Service
public class ResumeServiceImpl implements ResumeService {

    @Autowired
    private ResumeDao resumeDao;


    @Override
    public int checkResumeOpenStatusByUserId(long userId) {

        Resume exampleResume = new Resume();
        exampleResume.setUserId(userId);
        exampleResume.setIsDefault(1);
        Example<Resume> example = Example.of(exampleResume);
        Resume resume = resumeDao.findOne(example).get();
        if(resume != null){
            return resume.getIsOpenResume();
        }
        return -1;
    }
}
